#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>

void * Entry(void * arg)
{
    (void) arg;

    while(1)
    {
       printf("new thread\n");
       sleep(1);
    }
}

void test()
{
    pthread_t thread_1;
    pthread_create(&thread_1,NULL,Entry,NULL);
    int count=5;
    while(1)
    {
        printf("main thread\n");
        sleep(1);
        if(count--==0)
        {
            pthread_cancel(thread_1);
        }
    }
    pthread_join(thread_1,NULL);
}

int main()
{
    test();
    return 0;
}
